package com.method;

/**
 * @功能：练习
 * @版本： V1
 * @版权： 信息技术有限公司（http://www.mychery.com/）
 * @作者： 磐石战队开发组  00355760
 * @日期： 2024/8/5 10:54
 */

/**
 *         写4个方法：加减乘除
 *         利用循环+switch进行用户交互
 *         传递需要操作的两个数
 *         输出结果
 */

import java.util.Scanner;
public class demo07 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double result = 0;
        System.out.println("The program ends when you enter any letter!\nPlese input your number:");
        while(scanner.hasNextDouble()){
            double number1 = scanner.nextDouble();
            System.out.println("Plese input your Operation symbol:");
            String oper = scanner.next();
            System.out.println("Plese input your next number:");
            double number2 = scanner.nextDouble();
            switch (oper) {
                case "+":
                    result = add(number1, number2);
                    System.out.println("your result is " + result);
                    break;
                case "-":
                    result = reduce(number1, number2);
                    System.out.println("your result is " + result);
                    break;
                case "*":
                    result = ride(number1, number2);
                    System.out.println("your result is " + result);
                    break;
                case "/":
                    result = except(number1, number2);
                    System.out.println("your result is " + result);
                    break;
                default:
                    System.out.println("reinput");
            }
            System.out.println("===========================================\nThe program ends when you enter any letter!\nor Continue input your new number:");
        }
        scanner.close();
    }
    public static double add ( double a, double b){
        double value = 0;
        value = a + b;
        return value;
    }
    public static double reduce ( double a, double b){
        double value = 0;
        value = a - b;
        return value;
    }
    public static double ride ( double a, double b){
        double value = 0;
        value = a * b;
        return value;
    }
    public static double except ( double a, double b){
        double value = 0;
        value = a / b;
        return value;
    }
}
